Skip to content

fix(deps_security): propagate context.Context through security advisory HTTP call#30577

Merged
pelikhan merged 2 commits intomainfrom
copilot/add-context-to-query-security-advisories
May 6, 2026
Merged

fix(deps_security): propagate context.Context through security advisory HTTP call#30577
pelikhan merged 2 commits intomainfrom
copilot/add-context-to-query-security-advisories

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 6, 2026

querySecurityAdvisories made an outbound HTTP request with no context.Context, so it could not be cancelled by callers (e.g. Ctrl+C) and couldn't participate in context propagation chains. The only cancellation mechanism was the 30s client-level timeout.

Changes

  • pkg/cli/deps_security.go: Add ctx context.Context to CheckSecurityAdvisories and querySecurityAdvisories; replace http.NewRequest with http.NewRequestWithContext
  • pkg/cli/deps_report.go: Add ctx context.Context to GenerateDependencyReport; propagate to CheckSecurityAdvisories
  • pkg/cli/upgrade_command.go: Add ctx context.Context to runDependencyAudit; source context from cmd.Context() and propagate down
// Before
func querySecurityAdvisories(depVersions map[string]string, verbose bool) ([]SecurityAdvisory, error) {
    req, err := http.NewRequest(http.MethodGet, url, nil)

// After
func querySecurityAdvisories(ctx context.Context, depVersions map[string]string, verbose bool) ([]SecurityAdvisory, error) {
    req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh gh repo view --json owner,name --jq .owner.login + "/" + .name x_amd64/link ignore-path ../.git util (http block)
    • Triggering command: /usr/bin/gh /usr/bin/gh api graphql -f query=query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } -f owner=github -f name=gh-aw %H %ct %D (http block)
    • Triggering command: /usr/bin/gh /usr/bin/gh api graphql -f query=query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } -f owner=github -f name=gh-aw er_test ude_engine_netwouser.email ude_engine_test.test@example.com ache�� uypkflb2T ude_mcp.go Name,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle se_entity_helper/usr/bin/git ex_engine.go r ortcfg (http block)
  • https://api.github.com/orgs/test-owner/actions/secrets
    • Triggering command: /usr/bin/gh gh api /orgs/test-owner/actions/secrets --jq .secrets[].name h ../../../.prettierignore (http block)
  • https://api.github.com/repos/actions/ai-inference/git/ref/tags/v1
    • Triggering command: /usr/bin/gh gh api /repos/actions/ai-inference/git/ref/tags/v1 --jq [.object.sha, .object.type] | @tsv --show-toplevel node /usr/bin/git 73 ../../../**/*.jsrev-parse /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git runs/20260506-11gh config "warnings":[]}] git (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v3
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v3 --jq [.object.sha, .object.type] | @tsv --show-toplevel ache/go/1.25.8/xremote.origin.url /usr/bin/git log.showsignaturgh log bin/sh git rev-�� --show-toplevel ache/go/1.25.8/x64/pkg/tool/linuconfig /usr/bin/git LsRemoteWithRealgit LsRemoteWithRealrev-parse ache/go/1.25.8/x--show-toplevel /usr/bin/git (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v5
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq [.object.sha, .object.type] | @tsv npx prettier --write '**/*.cjs' '**/*.ts' '**/*.-test.timeout=10m0s -tests e/git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq [.object.sha, .object.type] | @tsv ithub-script/git/ref/tags/v9 /usr/bin/git bject.type] | @tsv byx2/jNQYSQDdMsvgit (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq [.object.sha, .object.type] | @tsv --show-toplevel infocmp /usr/bin/infocmp xterm-color /opt/hostedtoolcrev-parse /usr/bin/git infocmp -1 xterm-color git /usr/bin/git --show-toplevel 64/pkg/tool/linurev-parse /usr/bin/gh git (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v6
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv runs/20260506-112643-14520/test-3903350903 -trimpath (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv v1.0.0 rev-parse /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linu--limit yphen3179312139/git yphen3179312139/rev-parse x_amd64/vet /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/compile -o /tmp/go-build3172755196/b455/_pkg_.a -trimpath /usr/bin/git -p github.com/githurev-parse -lang=go1.25 git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv -test.paniconexit0 -test.v=true r,url,status,conclusion,workflowName,createdAt,s-nilfunc -test.timeout=10git -test.run=^Test -test.short=true--show-toplevel git conf�� user.name Test User /usr/lib/git-core/git th .prettierignogit core.hooksPath ode_modules/.bin--show-toplevel /usr/lib/git-core/git (http block)
  • https://api.github.com/repos/actions/github-script/git/ref/tags/v8
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq [.object.sha, .object.type] | @tsv xterm-color node /usr/bin/git /home/REDACTED/worgit 64/pkg/tool/linurev-parse (http block)
  • https://api.github.com/repos/actions/github-script/git/ref/tags/v9
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v9 --jq [.object.sha, .object.type] | @tsv urity-advisoriespkg/workflow/security_regression_test.go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v9 --jq [.object.sha, .object.type] | @tsv (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v9 --jq [.object.sha, .object.type] | @tsv from .github/aw to pkg/actionpins/data/action_pi**/*.ts ame x_amd64/vet (http block)
  • https://api.github.com/repos/actions/github-script/git/ref/tags/v9.0.0
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v9.0.0 --jq [.object.sha, .object.type] | @tsv urity-advisories (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v9.0.0 --jq [.object.sha, .object.type] | @tsv (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v9.0.0 --jq [.object.sha, .object.type] | @tsv -c=4 -nolocalimports -importcfg /tmp/go-build3172755196/b390/importcfg -pack /home/REDACTED/work/gh-aw/gh-aw/internal/tools/actions-build/main.go x_amd64/vet /pre�� */*.ts' '**/*.json' --ignore-path ../../../.pret.prettierignore --global /sh http.https://git/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/compile (http block)
  • https://api.github.com/repos/actions/setup-go/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-go/git/ref/tags/v4 --jq [.object.sha, .object.type] | @tsv --show-toplevel sh /usr/bin/gh 277088283 -tests e/git gh api /repos/actions/github-script/git/ref/tags/v9 --jq /usr/bin/git "prettier" --wrigit tname) ache/go/1.25.8/x--show-toplevel git (http block)
  • https://api.github.com/repos/actions/setup-node/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq [.object.sha, .object.type] | @tsv rhysd/actionlint:latest -dwarf=false /usr/bin/git go1.25.8 -c=4 -nolocalimports git -C /tmp/gh-aw-test-runs/20260506-112643-14520/test-277088283 rev-parse /usr/bin/git @{u} on bin/node git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq [.object.sha, .object.type] | @tsv --show-toplevel sh /usr/bin/git npx prettier --winfocmp (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq [.object.sha, .object.type] | @tsv --show-toplevel ache/node/24.14.1/x64/bin/node /usr/bin/git y config /usr/bin/infocmp--show-toplevel git rev-�� /ref/tags/v9 infocmp sv res_import_test.infocmp t_schema_test.go-1 64/pkg/tool/linuxterm-color gh (http block)
  • https://api.github.com/repos/actions/setup-node/git/ref/tags/v6
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv /tmp/go-build3172755196/b436/repoutil.test -importcfg (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv k/gh-aw/gh-aw/.github/workflows/api-consumption-report.md k/gh-aw/gh-aw/pkg/timeutil/format_test.go /usr/bin/git latted/flatted.ggit --get x_amd64/vet git conf�� runs/20260506-112643-14520/test-277088283 remote.origin.url /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/compile s/test.md --local 64/pkg/tool/linu--show-toplevel /opt/hostedtoolcache/go/1.25.8/x--jq (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv ansitiveImports1905326415/001 64/pkg/tool/linu-extld=gcc /usr/bin/git --local cfg 64/pkg/tool/linu--show-toplevel git conf�� user.email test@example.com /opt/hostedtoolcache/node/24.14.1/x64/bin/node 01028650/001 01028650/002/worrev-parse ode_modules/.bin--show-toplevel /opt/hostedtoolcache/node/24.14.1/x64/bin/node (http block)
  • https://api.github.com/repos/actions/upload-artifact/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/upload-artifact/git/ref/tags/v4 --jq [.object.sha, .object.type] | @tsv /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq /usr/bin/infocmp on' --ignore-patgit cfg 64/pkg/tool/linu--show-toplevel infocmp -1 xterm-color 64/pkg/tool/linuremote (http block)
  • https://api.github.com/repos/aws-actions/configure-aws-credentials/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/aws-actions/configure-aws-credentials/git/ref/tags/v4 --jq [.object.sha, .object.type] | @tsv --show-toplevel git /usr/bin/git /tmp/TestGuardPogit rev-parse /opt/hostedtoolc--show-toplevel git rev-�� --show-toplevel /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linuowner/repo /usr/bin/git -bool -buildtags ipts.test git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/aws-actions/configure-aws-credentials/git/ref/tags/v4 --jq [.object.sha, .object.type] | @tsv --show-toplevel git /usr/bin/git /tmp/TestGuardPogh l /opt/hostedtoolc/repos/actions/github-script/git/ref/tags/v9 git rev-�� /ref/tags/v9 node sv /tmp/TestHashCongit l /usr/bin/git infocmp (http block)
  • https://api.github.com/repos/azure/login/git/ref/tags/v2
    • Triggering command: /usr/bin/gh gh api /repos/azure/login/git/ref/tags/v2 --jq [.object.sha, .object.type] | @tsv --show-toplevel /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/compile /usr/bin/git /tmp/go-build317git -trimpath /opt/hostedtoolc--show-toplevel git rev-�� --show-toplevel node /usr/bin/git /tmp/TestHashConinfocmp l /usr/bin/git git (http block)
  • https://api.github.com/repos/docker/login-action/git/ref/tags/v3
    • Triggering command: /usr/bin/gh gh api /repos/docker/login-action/git/ref/tags/v3 --jq [.object.sha, .object.type] | @tsv --show-toplevel ache/node/24.14.1/x64/bin/node /usr/bin/git -test.paniconexigit 2755196/b463/_terev-parse /opt/hostedtoolc--show-toplevel git rev-�� --show-toplevel node /usr/bin/infocmp /tmp/TestHashConinfocmp 64/pkg/tool/linu-1 om/owner/repo.gixterm-color infocmp (http block)
  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v0.1.2
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v0.1.2 --jq [.object.sha, .object.type] | @tsv /repos/actions/github-script/git/ref/tags/v9 --jq /usr/bin/git runs/20260506-11gh c eutil.test git rev-�� --show-toplevel eutil.test /usr/bin/git --write scripts/**/*.js (http block)
  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v1.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.0.0 --jq [.object.sha, .object.type] | @tsv /v1.0.0 Test User sv 466903439/001 466903439/002/worev-parse 64/pkg/tool/linu--show-toplevel git conf�� --get remote.origin.url (http block)
  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v1.2.3
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.2.3 --jq [.object.sha, .object.type] | @tsv --show-toplevel 64/pkg/tool/linux_amd64/vet /usr/bin/git --local gpg.program 64/pkg/tool/linu--show-toplevel git rev-�� --show-toplevel 64/pkg/tool/linurev-parse /usr/bin/git ../pkg/workflow/git (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --limit 100 --created >=2026-04-29 (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --limit 100 --created >=2026-04-06 main -lang=go1.25 -MlvCPy/t6M8s7Cmremote.origin.url pret�� .js' --ignore-path .prettierignoremote.origin.url scripts/**/*.js ules/.bin/node .prettierignore --log-level=erroconfig -importcfg ache/go/1.25.8/xtest@example.com (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --limit 100 --created >=2026-02-05 chr/testify/requremote cmd/gh-aw/format_list_test.go ache/go/1.25.8/x64/pkg/tool/linuremote /opt�� .js' --ignore-path .prettierignore --log-level=error --write x_amd64/compile --ignore-path .prettierignore --log-level=erromaster x_amd64/compile (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/1/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/1/artifacts --jq .artifacts[].name !../../../pkg/workflow/js/**/*.json son ignore (http block)
    • Triggering command: /usr/bin/gh gh run download 1 --dir test-logs/run-1 ../../../**/*.json in/node --ignore-path onpins (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/12345/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/12345/artifacts --jq .artifacts[].name (http block)
    • Triggering command: /usr/bin/gh gh run download 12345 --dir test-logs/run-12345 (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/1234567890
    • Triggering command: /usr/bin/gh gh api repos/{owner}/{repo}/actions/runs/1234567890 --jq {databaseId: .id, number: .run_number, url: .html_url, status: .status, conclusion: .conclusion, workflowName: .name, workflowPath: .path, createdAt: .created_at, startedAt: .run_started_at, updatedAt: .updated_at, event: .event, headBranch: .head_branch, 76709288/001' 76709288/001' x_amd64/vet http.https://git/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/link (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/12346/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/12346/artifacts --jq .artifacts[].name (http block)
    • Triggering command: /usr/bin/gh gh run download 12346 --dir test-logs/run-12346 (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/2/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/2/artifacts --jq .artifacts[].name ../../../**/*.json son ignore ../../../.pretticonfig (http block)
    • Triggering command: /usr/bin/gh gh run download 2 --dir test-logs/run-2 ../../../**/*.json e_modules/.bin/node --ignore-path ../../../.prettiinit (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/3/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/3/artifacts --jq .artifacts[].name ../../../**/*.json son ignore ../../../.pretti/tmp/test-process-3264300044.js (http block)
    • Triggering command: /usr/bin/gh gh run download 3 --dir test-logs/run-3 ../../../**/*.json k/node_modules/.bin/node --ignore-path ../../../.prettirev-parse (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/4/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/4/artifacts --jq .artifacts[].name ../../../**/*.json son ignore ../../../.prettirev-parse (http block)
    • Triggering command: /usr/bin/gh gh run download 4 --dir test-logs/run-4 ../../../**/*.json es/.bin/node --ignore-path ../../../.pretticonfig (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/5/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/5/artifacts --jq .artifacts[].name ../../../**/*.json son ignore ../../../.pretticonfig (http block)
    • Triggering command: /usr/bin/gh gh run download 5 --dir test-logs/run-5 ../../../**/*.json k/gh-aw/node_modules/.bin/node --ignore-path ../../../.prettirev-parse (http block)
  • https://api.github.com/repos/github/gh-aw/actions/workflows
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path h ../../../.prettierignore --global x_amd64/vet http.https://git/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --workflow nonexistent-workflow-12345 --limit 100 -pack /home/REDACTED/work/gh-aw/gh-aw/pkg/timeutil/format.go /home/REDACTED/work/gh-aw/gh-aw/pkg/timeutil/format_test.go rev-�� ted/golang/pkg/flatted/flatted.go cfg 64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --workflow nonexistent-workflow-12345 --limit 6 (http block)
  • https://api.github.com/repos/github/gh-aw/contents/.github/workflows/shared/reporting.md
    • Triggering command: /tmp/go-build3172755196/b404/cli.test /tmp/go-build3172755196/b404/cli.test -test.testlogfile=/tmp/go-build3172755196/b404/testlog.txt -test.paniconexit0 -test.v=true -test.parallel=4 -test.timeout=10m0s -test.run=^Test -test.short=true (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v0.47.4
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v0.47.4 --jq [.object.sha, .object.type] | @tsv --show-toplevel git /usr/bin/git --get remote.origin.ur-k /usr/bin/git git rev-�� /ref/tags/v9 git sv --show-toplevel 64/pkg/tool/linurev-parse /usr/bin/git infocmp (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v1.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.0.0 --jq [.object.sha, .object.type] | @tsv 841684004/001 sRemoteWithRealGitmaster_branch3466903439/002/work g_.a -errorsas -ifaceassert erignore /opt/hostedtoolcache/go/1.25.8/xremote.origin.url -ato�� te '../../../**/*.json' '!../../../pkg/workflow/js/**/*.json' ---p -buildtags 64/pkg/tool/linux_amd64/vet -errorsas -ifaceassert -nilfunc 64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v1.2.3
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.2.3 --jq [.object.sha, .object.type] | @tsv 1306550972/.github/workflows cfg 64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v2.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq [.object.sha, .object.type] | @tsv 1306550972 cfg 64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq [.object.sha, .object.type] | @tsv on' --ignore-path ../../../.pret.prettierignore cfg _modules/.bin/node (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq [.object.sha, .object.type] | @tsv on' --ignore-path ../../../.prettierignore cfg 64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v3.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v3.0.0 --jq [.object.sha, .object.type] | @tsv on' --ignore-pat-c=4 cfg 64/pkg/tool/linu-importcfg ata/action_pins.git (http block)
  • https://api.github.com/repos/google-github-actions/auth/git/ref/tags/v2
    • Triggering command: /usr/bin/gh gh api /repos/google-github-actions/auth/git/ref/tags/v2 --jq [.object.sha, .object.type] | @tsv --show-toplevel git /usr/bin/git --show-toplevel x_amd64/vet /usr/bin/gh git rev-�� --show-toplevel gh /usr/bin/git /repos/actions/ggit l /usr/bin/git git (http block)
  • https://api.github.com/repos/nonexistent/action/git/ref/tags/v999.999.999
    • Triggering command: /usr/bin/gh gh api /repos/nonexistent/action/git/ref/tags/v999.999.999 --jq [.object.sha, .object.type] | @tsv -bool -buildtags .cfg -errorsas -ifaceassert ode-gyp-bin/node--get-regexp /opt/hostedtoolc^remote\..*\.gh-resolved$ -ato�� 2643-14520/test-1762447348/.githremote.origin.url -buildtags 64/pkg/tool/linux_amd64/vet -errorsas -ifaceassert -nilfunc 64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/nonexistent/repo/actions/runs/12345
    • Triggering command: /usr/bin/gh gh run view 12345 --repo nonexistent/repo --json status,conclusion nore (http block)
  • https://api.github.com/repos/owner/repo/actions/workflows
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo x_amd64/vet http.https://git/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo /sh http.https://git/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh workflow list --repo owner/repo --json name,path,state 532568/b353/vet.cfg (http block)
  • https://api.github.com/repos/test-owner/test-repo/actions/secrets
    • Triggering command: /usr/bin/gh gh api /repos/test-owner/test-repo/actions/secrets --jq .secrets[].name h ../../../.prettierignore (http block)
  • https://api.github.com/repos/test/repo
    • Triggering command: /usr/bin/gh gh api /repos/test/repo --jq .default_branch t3667621102/.github/workflows /tmp/go-build167532568/b143/vet.cfg .cfg (http block)

If you need me to access, download, or install something from one of these locations, you can either:

…d callers

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/63dfc8dd-7428-4a3d-a826-05f1c4ff35c9

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Copilot AI changed the title [WIP] Add context parameter to querySecurityAdvisories HTTP call fix(deps_security): propagate context.Context through security advisory HTTP call May 6, 2026
Copilot AI requested a review from gh-aw-bot May 6, 2026 11:30
@pelikhan pelikhan marked this pull request as ready for review May 6, 2026 11:32
Copilot AI review requested due to automatic review settings May 6, 2026 11:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Propagates context.Context through the dependency security advisory check so outbound HTTP requests can be cancelled (e.g., via Ctrl+C) and participate in context cancellation/deadline chains.

Changes:

  • Thread ctx context.Context through the dependency audit/report/security advisory functions.
  • Use http.NewRequestWithContext for the GitHub Security Advisory API call.
  • Source the context from cmd.Context() in the upgrade command’s audit path.
Show a summary per file
File Description
pkg/cli/deps_security.go Adds ctx to advisory-check functions and binds it to the outbound HTTP request via NewRequestWithContext.
pkg/cli/deps_report.go Adds ctx to report generation and propagates it into the security advisory check.
pkg/cli/upgrade_command.go Passes cmd.Context() into the dependency audit/report generation flow.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 3/3 changed files
  • Comments generated: 0

@pelikhan pelikhan merged commit 231206a into main May 6, 2026
96 of 106 checks passed
@pelikhan pelikhan deleted the copilot/add-context-to-query-security-advisories branch May 6, 2026 11:44
@github-actions github-actions Bot mentioned this pull request May 6, 2026
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skills-Based Review 🧠

Applied /diagnose (this is a bug fix — HTTP request couldn't be cancelled) and /tdd (checking test coverage for the changed paths).

Key Themes

  • Fix is correct and idiomatichttp.NewRequestWithContext is the right Go pattern; the 30s client timeout and caller-supplied context now complement each other correctly.
  • Context threading is complete — the context flows cleanly from cmd.Context()runDependencyAuditGenerateDependencyReportCheckSecurityAdvisoriesquerySecurityAdvisories → the HTTP request. No leaks or short-circuits.
  • Missing regression testdeps_test.go has no coverage for CheckSecurityAdvisories or querySecurityAdvisories. Per /diagnose Phase 5, a regression test should lock down the fix so a future refactor that accidentally drops the context is caught immediately. See the inline comment for a concrete example using httptest.

Positive Highlights

  • ✅ Minimal, surgical change — only the lines that needed updating were touched.
  • cmd.Context() is the right source for the root context in a Cobra command — no manual context.Background() threading required.
  • ✅ Both the client-level Timeout: 30s and context cancellation are preserved; they're orthogonal safety nets.

Verdict

The fix is sound. The only notable gap is a regression test to verify that a cancelled context propagates through to the HTTP call. Leaving as COMMENT rather than REQUEST_CHANGES since the test is a nice-to-have for a small one-function change, but adding it would make the fix complete end-to-end.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · ● 5M

Comment thread pkg/cli/deps_security.go
depsSecurityLog.Printf("Querying GitHub Security Advisory API: url=%s, dep_count=%d", url, len(depVersions))
client := &http.Client{Timeout: 30 * time.Second}
req, err := http.NewRequest(http.MethodGet, url, nil)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/diagnose] The fix is correct — http.NewRequestWithContext is the right call here. Per the /diagnose Phase 5 guidance, a regression test at the correct seam should accompany the fix.

Consider adding a test that verifies context cancellation is honoured, for example using httptest.NewServer with a handler that blocks, then cancelling the context:

func TestCheckSecurityAdvisories_ContextCancelled(t *testing.T) {
    srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
        <-r.Context().Done()
    }))
    defer srv.Close()

    ctx, cancel := context.WithCancel(context.Background())
    cancel() // cancel immediately

    _, err := CheckSecurityAdvisories(ctx, false)

    assert.Error(t, err, "cancelled context should produce an error")
}

Without this, the only assurance that context wiring is correct is code inspection — it won't catch a regression if the context is inadvertently dropped in a future refactor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pkg/cli: querySecurityAdvisories HTTP call missing context.Context parameter

4 participants